library(ggplot2)
library(reshape2)

cat("Path to correction series >> ")
series.dir <- readLines(n=1)

fs <- list.files(path=series.dir, full.names=TRUE)

out.dir <- file.path(series.dir, 'plots_out')
dir.create(out.dir)

for (f in fs) {
    d <- read.csv(f)
    d <- d[c('qv_series', 'vol')]
    d <- transform(d, index=1:nrow(d))
    d <- d[! names(d) %in% c('flow', 'velocity', 'length')]
    dm <- melt(d, id.vars='index')
    p <- ggplot(dm, aes(index, value, col=variable)) + geom_line() + ggtitle(basename(f))
    plot.out <- file.path(out.dir, paste0(tools::file_path_sans_ext(basename(f)), '.png'))
    ggsave(plot.out, plot=p)
}

